//是否统一结算
function changeJieSuan() {
	if (document.forms[0].UNIFIED_FLAG.value == 0) {
		document.getElementById("shopBase").style.display = "inline-block";
	} else {
		document.getElementById("shopBase").style.display = "none";
	}
}

function getAcctInfo() {
	var SHOP_AC = document.all.SHOP_AC.value;
	if (null == SHOP_AC || SHOP_AC.length == 0) {
		alert("请输入总店商户名称");
		return false;
	} else {
		$
				.post("basicActionCopyInfo.action",
						{
							//往action中传入参数
						SHOP_AC : $("#SHOP_AC").val()
					},
						function(returnedData, status) {
							if ("success" == status) {
								var id = $(returnedData).find("merchList").text();
								var merchs = eval('(' + id + ')');
								var str = "<table id=chaxun width=100% align=left class=tablebox>";
								for ( var i = 0; i < merchs.length; i++) {
									str = str
											+ "<tr>"
											+ "<td>"
											+ merchs[i].mERCH_ID
											+ "</td>"
											+ "<td>"
											+ merchs[i].mERCH_NAME
											+ "</td>"
											+ "<td>"
											+ "<input type=button value=复制 Class=btn_submit onClick=setAcctInfo('"
											+ merchs[i].mERCH_ID
											+ "'); onmouseover=this.className='btn_submit_k' onmouseout=this.className='btn_submit' />"
											+ "</td>" + "</tr>";

								}
								str = str + "<table>";
								document.getElementById("jsondiv").innerHTML = str;
								document.getElementById("fuzhi").style.display = "inline-block";
							}
						});
	}
}

function setAcctInfo(id) {
	$.post("basicActionCopy.action", {
		//往action中传入参数
			SHOP_ID : id
		}, function(returnedData, status) {
			if ("success" == status) {

				var id = $(returnedData).find("merchId").text();
				var name = $(returnedData).find("name").text();
				var age = $(returnedData).find("age").text();
				var address = $(returnedData).find("address").text();

				document.getElementById("RCV_BANK_NAME").value = id;
				document.getElementById("RCV_ACC").value = name;
				document.getElementById("RCV_BANK").value = age;
				document.getElementById("RCV_NAME").value = address;
				document.getElementById("fuzhi").style.display = "none";
			}
		});
}

//提交商户账户信息
$(document).ready(function() {
	//如果是必填的，则加红星标识.
		$("[class^='required']").each(function() {
			var $required = $("<strong class='high'> *</strong>"); //创建元素
				$(this).parent().append($required); //然后将它追加到文档中
			});
		$("[class^='{required']").each(function() {
			var $required = $("<strong class='high'> *</strong>"); //创建元素
				$(this).parent().append($required); //然后将它追加到文档中
			});
		$('#send').click(function() {
			var validator = $('#addForm').validate();
			if (validator.form()) {
			
				var a=document.getElementById("MERCH_NAME").value;
				var b=document.getElementById("RCV_NAME").value;
				var c=document.getElementById("COMPANYR").value;
				
				if(c=="0"&&a!=b)
				{
					alert("当公司关系为正常的时候,商户名称要与收款单位名称相同");
				}
				else
				{
					$("#addForm").submit();
				}
			}
		});
	});